//
// Created by Administrator on 2024/6/10 0010.
//

#ifndef HELLOFFMPEG_RTSPPLAYER_H
#define HELLOFFMPEG_RTSPPLAYER_H
#include <jni.h>
#include <string>

extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
#include <libavutil/imgutils.h>
#include <libswscale/swscale.h>
#include <android/native_window.h>
#include <android/native_window_jni.h>
}

class RtspPlayer{
public:
    RtspPlayer();
    ~RtspPlayer();
    bool openStream(const std::string &url);
    void decodeAndPlay(JNIEnv *env, jobject surface);

private:
    AVFormatContext *formatContext;
    AVCodecContext *codecContext;
    AVFrame *frame;
    AVPacket *packet;
    SwsContext *swsContext;
    int videoStreamIndex;

    bool initialize();
    void release();
};




#endif //HELLOFFMPEG_RTSPPLAYER_H
